package com.sweet.entity;

import com.sweet.enums.MessageType;
import io.vertx.core.json.JsonObject;

/**
 * Created by sweet on 2019/2/13.
 * ---------------------------
 */
public class ClientAckMessage {

  private final String id;

  private final String token;

  private final MessageType type;

  public ClientAckMessage(String id, String token, MessageType type) {
    this.id = id;
    this.token = token;
    this.type = type;
  }

  public MessageType getType() {
    return type;
  }

  public String getToken() {
    return token;
  }

  public String getId() {
    return id;
  }

  public static ClientAckMessage fromJson(JsonObject jsonObject) {
    return new ClientAckMessage(jsonObject.getString("id"), jsonObject.getString("token"),
        jsonObject.getString("type").equals(MessageType.ACK) ? MessageType.ACK : MessageType.TEXT);
  }

  @Override
  public String toString() {
    return "ClientAckMessage{" +
        "id='" + id + '\'' +
        ", token='" + token + '\'' +
        ", type=" + type +
        '}';
  }
}
